
package org.soekrat.gui.swing.motor.wheelpassingstrategy;

public class StringArrayLookAhead implements LookaheadTextField.TextLookAhead 
{
  public StringArrayLookAhead(){ values = new String[0]; }

  public StringArrayLookAhead(String[] values){ this.values = values; }

  public void setValues(String[] values){ this.values = values; }

  public String[] getValues(){ return values; }

  public String doLookAhead(String key) 
  {
    int length = values.length;

    // Look for a string that starts with the key
    for (int i = 0; i < length; i++) 
    {
      if (values[i].startsWith(key) == true)
      {
        return values[i];
      }
    }

    // No match found - return null
    return null;
  }

  protected String[] values;

}
